﻿using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml;

namespace Lm.Common.Excel.OpenXml
{
    /// <summary>
    ///   Cell.StyleIndex = 0,日期
    ///   Cell.StyleIndex = 1,人民币￥
    /// </summary>
    public class StyleSheetGenerator
    {
        public Stylesheet Generate()
        {
            Stylesheet stylesheet1 = new Stylesheet();

            #region 格式化

            NumberingFormats numberingFormats1 = new NumberingFormats();
            NumberingFormat numberingFormat1 = new NumberingFormat() { NumberFormatId = (UInt32Value)177U, FormatCode = "yyyy/m/d\\ h:mm;@" };
            numberingFormats1.Append(numberingFormat1);
            NumberingFormat numberingFormat2 = new NumberingFormat() { NumberFormatId = (UInt32Value)179U, FormatCode = "\"¥\"#,##0.00_);[Red]\\(\"¥\"#,##0.00\\)" };
            numberingFormats1.Append(numberingFormat2);

            CellFormats cellFormats1 = new CellFormats();
            CellFormat cellFormat101 = new CellFormat() { NumberFormatId = (UInt32Value)177U, };
            cellFormats1.Append(cellFormat101);
            CellFormat cellFormat102 = new CellFormat() { NumberFormatId = (UInt32Value)179U, };
            cellFormats1.Append(cellFormat102);

            #endregion

            #region 没用，但不能删

            Fonts fonts1 = new Fonts();
            Font font1 = new Font();
            fonts1.Append(font1);

            Fills fills1 = new Fills();
            Fill fill1 = new Fill();
            fills1.Append(fill1);

            Borders borders1 = new Borders();
            Border border1 = new Border();
            borders1.Append(border1);

            CellStyleFormats cellStyleFormats1 = new CellStyleFormats();
            CellFormat cellFormat1 = new CellFormat();
            cellStyleFormats1.Append(cellFormat1);

            CellStyles cellStyles1 = new CellStyles();
            CellStyle cellStyle1 = new CellStyle() { FormatId = (UInt32Value)0U };
            cellStyles1.Append(cellStyle1);

            #endregion

            stylesheet1.Append(numberingFormats1);
            stylesheet1.Append(fonts1);
            stylesheet1.Append(fills1);
            stylesheet1.Append(borders1);
            stylesheet1.Append(cellStyleFormats1);
            stylesheet1.Append(cellFormats1);
            stylesheet1.Append(cellStyles1);

            return stylesheet1;
        }
    }
}




